<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 
      Teleport作用是将组件挂载在父元素以外的dom结构中

      对话框，悬浮框，请提示等需要根据窗口进行定位的元素
     -->
    <div id="app">
      <button @click="open = true">Open Modal</button>

      <div>
        <div>
          <Teleport to="body">
            <div v-if="open" class="modal">
              <p>Hello from the modal!</p>
              <button @click="open = false">Close</button>
            </div>
          </Teleport>
        </div>
      </div>
      <!-- <Teleport to="body"> -->

      <!-- </Teleport> -->
    </div>

    <script src="./lib/vue3.js"></script>
    <script>
      Vue.createApp({
        data() {
          return {
            open: false,
          };
        },
      }).mount("#app");
    </script>
  </body>
</html>
